package com.blb.zycommunity.mapper;

import com.blb.zycommunity.entity.SysPost;
import com.blb.zycommunity.entity.SysRole;
import com.blb.zycommunity.entity.SysUserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * 用户和角色关联表 Mapper 接口
 * </p>
 *
 * @author chenheng
 * @since 2023-11-20
 */
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
    @Delete("delete from sys_user_role where user_id = #{userId}")
    boolean deleteRoleByUserId(@Param("userId") Long userId);

    /**
     * 按用户名查询所有角色
     * @parasername
     * @return
     */
    List<SysRole> selectRolesByUsername(String username);

    /**
     * 按用户名查询所属岗位
     * @param username
     * @return
     */
    List<SysPost> selectPostByUsername(String username);
}
